/**
 * There are <a href="https://www.hdzhx.com">邯郸智讯</a> code generation
 */
package com.boxin.ims.modules.jiujiudevice.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.apache.noggit.JSONUtil;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.boxin.ims.modules.wechat.entity.JiuWechatMember;
import com.phoenix.common.lang.MathUtil;
import com.thinkgem.jeesite.common.mapper.JsonMapper;
import com.thinkgem.jeesite.common.persistence.BaseEntity;

/**
 * 订单记录Entity
 * @author sxh
 * @version 2018-08-15
 */
@Entity
@Table(name = "jiu_order_record")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class JiuOrderRecord extends BaseEntity {
	
	/**
	 * 已支付
	 */
	public static final Integer  STATUS_YES_PAY = 1;//支付
	/**
	 * 未支付
	 */
	public static final Integer  STATUS_NO_PAY= 0;//未支付
	
	public static final Integer  DEL_YES = 1;//删除
	public static final Integer  DEL_NO= 0;//未删除
	
	private static final long serialVersionUID = 1L;
	private Long id; 		// 编号
	
	private Long memberId;
	
	/**微信标识*/
	private String memberOpenId;
	/**会员手机号*/
	private String memberMobile;
	/**订单状态 0-未支付 1-支付 */
	private Integer status;
	/**支付时间*/
	private Date payTime;
	/**错误码*/
	private String errorCode;
	/**错误信息*/
	private String errorMessage;
	/**订单号*/
	private String orderNo;
	/**设备开始时间*/
	private Date beginTime;
	/**设备结束时间*/
	private Date endTime;
	/**设备使用时间*/
	private Date useTime;
	
	/**设备sn*/
	private String deviceSn;
	/**设备名称*/
	private String deviceName;
	/**消费总额*/
	private Double amount;
	/**公司id*/
	private Integer companyId;
	/**公司名称*/
	private String companyName;
	/**删除标识 0未删除， 1已删除*/
	private Integer delFlag;
	/**创建日期*/
	private Date createTime; 
    /**不映射*/
	private JiuOrderLog jiuOrderLog;
	/**不映射*/
	private JiuWechatMember jiuWechatMember;
	/**不映射*/
	private List<JiuInkRecord> jiuInkRecord;
	/**不映射*/
	private String  jiuInkRecordString;
	public JiuOrderRecord() {
		this.createTime = new Date();
/*	    this.delFlag = JiuOrderRecord.DEL_NO;
	    this.status = JiuOrderRecord.STATUS_NO_PAY;*/
	} 

	public JiuOrderRecord(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	@NotNull
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Long getMemberId() {
		return memberId;
	}

	public void setMemberId(Long memberId) {
		this.memberId = memberId;
	}

	public String getMemberOpenId() {
		return memberOpenId;
	}

	public void setMemberOpenId(String memberOpenId) {
		this.memberOpenId = memberOpenId;
	}

	public String getMemberMobile() {
		return memberMobile;
	}

	public void setMemberMobile(String memberMobile) {
		this.memberMobile = memberMobile;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getPayTime() {
		return payTime;
	}

	public void setPayTime(Date payTime) {
		this.payTime = payTime;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}



	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public Date getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Date getUseTime() {
		return useTime;
	}

	public void setUseTime(Date useTime) {
		this.useTime = useTime;
	}

	public String getDeviceSn() {
		return deviceSn;
	}

	public void setDeviceSn(String deviceSn) {
		this.deviceSn = deviceSn;
	}

	public String getDeviceName() {
		return deviceName;
	}

	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public Integer getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Integer companyId) {
		this.companyId = companyId;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}

	public static String generateOrderNo() {
		return "NO"+((int)((Math.random()*9+1)*10000))+System.currentTimeMillis();
	}

	 @Transient
	public JiuOrderLog getJiuOrderLog() {
		return jiuOrderLog;
	}

	public void setJiuOrderLog(JiuOrderLog jiuOrderLog) {
		this.jiuOrderLog = jiuOrderLog;
	}
	 @Transient
	public JiuWechatMember getJiuWechatMember() {
		return jiuWechatMember;
	}

	public void setJiuWechatMember(JiuWechatMember jiuWechatMember) {
		this.jiuWechatMember = jiuWechatMember;
	}

	@Transient
	public List<JiuInkRecord> getJiuInkRecord() {
		return jiuInkRecord;
	}

	public void setJiuInkRecord(List<JiuInkRecord> jiuInkRecord) {
		this.jiuInkRecord = jiuInkRecord;
	}
	@Transient
	public String getJiuInkRecordString() {
		if(this.jiuInkRecord != null){
			return JsonMapper.getInstance().toJsonString(this.jiuInkRecord);
		}else{
			return "";
		}
	}

	public void setJiuInkRecordString(String jiuInkRecordString) {
		this.jiuInkRecordString = jiuInkRecordString;
	}
}


